package com.interview.ujiuye7;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * Copyright (C), 2018-2020
 * FileName: MyClient
 * Author:   kongfanyu
 * Date:     2020/11/9 11:47
 */
public class MyClient {
    public static void main(String[] args) throws Exception{
        Socket socket = new Socket("localhost",8080);

        OutputStream outputStream = socket.getOutputStream();//输出流
        PrintWriter pw = new PrintWriter(outputStream,true);//把字节流包装成字符流
        pw.println("加班学习.....");

        InputStream inputStream = socket.getInputStream();//输入流
        InputStreamReader isr = new InputStreamReader(inputStream);
        char cbuf[] = new char[1024];
        int len = isr.read(cbuf);
        System.out.println("服务器说:"+new String(cbuf,0,len));

        pw.close();
        socket.close();
    }
}
